-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rename ephemeral_storage to disk for simplicity #3095
base: master
Are you sure you want to change the base?
Rename ephemeral_storage to disk for simplicity #3095
Conversation
1. Support `ephemeral_storage` as an alias for backward compatibility and developer-facing code 2. Encourage users to switch to `disk` when configuring this property Signed-off-by: JiangJiaWei1103 <[email protected]>
Code Review Agent Run Status
|
Signed-off-by: JiangJiaWei1103 <[email protected]>
Code Review Agent Run Status
|
Signed-off-by: JiangJiaWei1103 <[email protected]>
`|` is supported for 3.10+, please see PEP 604. Signed-off-by: JiangJiaWei1103 <[email protected]>
Code Review Agent Run Status
|
Code Review Agent Run #c7015eActionable Suggestions - 3
Review Details
|
Changelist by BitoThis pull request implements the following key changes.
|
# This allocates 1Gi of such local storage. | ||
Resources(ephemeral_storage="1Gi") | ||
Resources(disk="1Gi") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider maintaining backward compatibility by keeping both disk
and ephemeral_storage
parameters functional. While renaming to disk
improves clarity, some existing code may still use ephemeral_storage
. Consider handling both parameters and adding a deprecation warning for ephemeral_storage
.
Code suggestion
Check the AI-generated fix before applying
- disk: InitVar[Optional[Union[str, int]]] = None
- ephemeral_storage: Optional[Union[str, int]] = None
+ disk: Optional[Union[str, int]] = None
+ ephemeral_storage: InitVar[Optional[Union[str, int]]] = None
def __post_init__(self, disk):
+ if disk is not None:
+ self.disk = disk
+ if self.ephemeral_storage is not None:
+ warnings.warn('The ephemeral_storage parameter is deprecated. Please use disk instead.', DeprecationWarning)
+ if self.disk is None:
+ self.disk = self.ephemeral_storage
Code Review Run #c7015e
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
@@ -33,9 +35,10 @@ class Resources(DataClassJSONMixin): | |||
cpu: Optional[Union[str, int, float]] = None | |||
mem: Optional[Union[str, int]] = None | |||
gpu: Optional[Union[str, int]] = None | |||
disk: InitVar[Optional[Union[str, int]]] = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using a consistent type annotation pattern for resource fields. While disk
is marked as InitVar
, other similar resource fields (cpu
, mem
, gpu
, ephemeral_storage
) are not. This inconsistency might lead to confusion in how these fields are processed.
Code suggestion
Check the AI-generated fix before applying
- cpu: Optional[Union[str, int, float]] = None
- mem: Optional[Union[str, int]] = None
- gpu: Optional[Union[str, int]] = None
- disk: InitVar[Optional[Union[str, int]]] = None
- ephemeral_storage: Optional[Union[str, int]] = None
+ cpu: InitVar[Optional[Union[str, int, float]]] = None
+ mem: InitVar[Optional[Union[str, int]]] = None
+ gpu: InitVar[Optional[Union[str, int]]] = None
+ disk: InitVar[Optional[Union[str, int]]] = None
+ ephemeral_storage: InitVar[Optional[Union[str, int]]] = None
Code Review Run #c7015e
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
# Specify only disk | ||
resources = Resources(cpu="1", mem="1Gi", gpu="1", disk="1Gi") | ||
assert resources.disk == "1Gi" | ||
assert resources.ephemeral_storage == "1Gi" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider removing redundant assertions since disk
and ephemeral_storage
are expected to have the same value. A single assertion would be sufficient to verify the behavior.
Code suggestion
Check the AI-generated fix before applying
assert resources.ephemeral_storage == "1Gi" |
Code Review Run #c7015e
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
Tracking issue
Closes flyteorg/flyte#6142.
Why are the changes needed?
The attribute
ephemeral_storage
ofResources
(i.e., K8s pod resources) is too complicated and should be simplified.What changes were proposed in this pull request?
At this stage, we propose to support both
disk
andephemeral_storage
for backward compatibility.The behavior of different configurations is summarized as follows:
disk
andephemeral_storage
are specified: Raise an errorephemeral_storage
is used: Warn users about the future deprecationdisk
is used: Usedisk
directly and allowephemeral_storage
to mirrordisk
valueHow was this patch tested?
Setup process
Screenshots
Check all the applicable boxes
Related PRs
Docs link
Summary by Bito
This PR renames 'ephemeral_storage' to 'disk' in the Resources class while maintaining backward compatibility through deprecation warnings. The implementation allows both attributes to function, with 'ephemeral_storage' mirroring the 'disk' value. The changes include comprehensive test coverage and improved parameter handling for better code clarity.Unit tests added: True
Estimated effort to review (1-5, lower is better): 1